import request from '@/utils/request'
import {AddMenuItem, CreateMenuItem, EditMenuItem, MenuListData} from "@/api/menu/type.ts";
import {ResponseData} from "@/api/types/type.ts";

export function getMenuList(): Promise<MenuListData> {
    return request({
        url: '/menu/getMenuList',
        method: 'get'
    })
}

export const CreateMenu = (data: CreateMenuItem): Promise<ResponseData> => {
    return request({
        url: '/menu/createMenu',
        method: 'post',
        data
    })
}
export const addChildItem = (data: AddMenuItem): Promise<ResponseData> => {
    return request({
        url: '/menu/addChildItem',
        method: 'post',
        data
    })
}
export const updateMenu = (data: EditMenuItem): Promise<ResponseData> => {
    return request({
        url: '/menu/update',
        method: 'post',
        data
    })
}

export const deleteMenu = (id: any): Promise<ResponseData> => {
    return request({
        url: `/menu/deleteMenu?id=${id}`,
        method: 'DELETE'
    })
}
